package com.hdax.dm.listnener;

import com.hdax.dm.beans.order.order;
import com.hdax.dm.feign.schedulerFeign;
import com.hdax.dm.service.queryorderlistService;
import com.hdax.dm.service.submitorderService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@RabbitListener(queues = "dm_order_dlx_queue")
@Component
public class MyRabbitListener {

    @Autowired
    private queryorderlistService queryorderlistService;

    @Autowired
    private submitorderService submitorderService;

    @Autowired
    private schedulerFeign schedulerFeign;
    @RabbitHandler
    public void rabbitHandler(String orderNo){
        //修改订单信息

        //如果该订单的状态是已支付则不用修改否则就要修改
        order order = queryorderlistService.pay(orderNo);
        if (order.getOrderType()!=2) {
            //修改订单状态
            queryorderlistService.Timeoutupdate(orderNo);
            //删除订单联系人
            submitorderService.deleteorderLinkUser(orderNo);
            //修改座位状态
            schedulerFeign.updateseat(orderNo);
            System.out.println("订单："+orderNo+"支付失败");
        }
    }
}
